package o;

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import javax.annotation.Nullable;

public abstract class fuw {

    class AnonymousClass1 extends fuw {
        final /* synthetic */ fup ˊ;
        final /* synthetic */ fxh ˏ;

        AnonymousClass1(fup o_fup, fxh o_fxh) {
            this.ˊ = o_fup;
            this.ˏ = o_fxh;
        }

        @Nullable
        public fup contentType() {
            return this.ˊ;
        }

        public long contentLength() throws IOException {
            return (long) this.ˏ.ʼ();
        }

        public void writeTo(fxj o_fxj) throws IOException {
            o_fxj.ˊ(this.ˏ);
        }
    }

    class AnonymousClass4 extends fuw {
        final /* synthetic */ int ˊ;
        final /* synthetic */ int ˋ;
        final /* synthetic */ fup ˏ;
        final /* synthetic */ byte[] ॱ;

        AnonymousClass4(fup o_fup, int i, byte[] bArr, int i2) {
            this.ˏ = o_fup;
            this.ˊ = i;
            this.ॱ = bArr;
            this.ˋ = i2;
        }

        @Nullable
        public fup contentType() {
            return this.ˏ;
        }

        public long contentLength() {
            return (long) this.ˊ;
        }

        public void writeTo(fxj o_fxj) throws IOException {
            o_fxj.ˋ(this.ॱ, this.ˋ, this.ˊ);
        }
    }

    class AnonymousClass5 extends fuw {
        final /* synthetic */ File ˋ;
        final /* synthetic */ fup ˏ;

        AnonymousClass5(fup o_fup, File file) {
            this.ˏ = o_fup;
            this.ˋ = file;
        }

        @Nullable
        public fup contentType() {
            return this.ˏ;
        }

        public long contentLength() {
            return this.ˋ.length();
        }

        public void writeTo(fxj o_fxj) throws IOException {
            Closeable closeable = null;
            try {
                closeable = fxr.ॱ(this.ˋ);
                o_fxj.ˋ((fxw) closeable);
            } finally {
                fvg.ॱ(closeable);
            }
        }
    }

    @Nullable
    public abstract fup contentType();

    public abstract void writeTo(fxj o_fxj) throws IOException;

    public long contentLength() throws IOException {
        return -1;
    }

    public static fuw create(@Nullable fup o_fup, String str) {
        Charset charset = fvg.ˎ;
        if (o_fup != null) {
            charset = o_fup.ॱ();
            if (charset == null) {
                charset = fvg.ˎ;
                o_fup = fup.ॱ(o_fup + "; charset=utf-8");
            }
        }
        return create(o_fup, str.getBytes(charset));
    }

    public static fuw create(@Nullable fup o_fup, fxh o_fxh) {
        return new AnonymousClass1(o_fup, o_fxh);
    }

    public static fuw create(@Nullable fup o_fup, byte[] bArr) {
        return create(o_fup, bArr, 0, bArr.length);
    }

    public static fuw create(@Nullable fup o_fup, byte[] bArr, int i, int i2) {
        if (bArr == null) {
            throw new NullPointerException("content == null");
        }
        fvg.ˎ((long) bArr.length, (long) i, (long) i2);
        return new AnonymousClass4(o_fup, i2, bArr, i);
    }

    public static fuw create(@Nullable fup o_fup, File file) {
        if (file != null) {
            return new AnonymousClass5(o_fup, file);
        }
        throw new NullPointerException("file == null");
    }
}
